package com.nowcoder.server;

import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

public class TcpServer {

    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(9000);
            while (true) {
                Socket socket = serverSocket.accept();
                System.out.println("请求: " + socket.toString());
                PrintStream ps = new PrintStream(socket.getOutputStream());
                ps.println("Welcome " + socket.getInetAddress().getHostAddress());
                socket.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
